<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
$isflag=$action->checkPermissions($user,$companyid);
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
    	<h2>
		<?php 
			$companyname=$session->read("companyname");
			echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
    	</h2>
    	<div class='clear'></div>
    </div>
    <div class="right back_btn"><?php echo $html->link("返回","/companys/depcosts/".$_SESSION['companyid'])?></div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
    	<div class="right_side_operate_area">
			<div class="right_side_title left">
    			<h3>研发费用投入</h3>
			</div>
			<div class="clear"></div>
		</div>
		<div class="details_item_line">
			<div class="details_item">
                <div class="form_left_title left"><?php echo "时间";?>：</div>
                <div class="form_right_input left"><?php echo date("Y-m-d",strtotime($cost['DevelopmentCost']['c_time'])) ;?></div>
            </div>
     </div>  
     <div class="details_item_line">     
            <div class="details_item">
                <div class="form_left_title left"><?php echo "总额";?>：</div>
                <?php $y="￥"; ?>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['cost'].$y ;?></div>
            </div>
     </div>
     <div class="details_item_line">     
            <div class="details_item">
                <div class="form_left_title left"><?php echo "占总营额比重";?>：</div>
                <?php $y="%"; ?>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['cost_percent'].$y ;?></div>
            </div>
     </div>
 	 <div class="details_item_line">     
	        <div class="details_item">
	            <div class="form_left_title left">研究与实验：</div>  
	            <div class="form_right_input left">
	            <?php echo $cost['DevelopmentCost']['research_exp'].$y ;?></div>
	        </div>   
            <div class="details_item">
             <div class="form_left_title left"><?php echo "新产品费用";?>：</div>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['new_product'].$y ;?></div>
            </div>
     	</div>
  	<div class="details_item_line">     
            <div class="details_item">
                <div class="form_left_title left"><?php echo "政府拨款";?>：</div>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['new_product'].$y ;?></div>
            </div>   
     	    <div class="details_item">
                <div class="form_left_title left"><?php echo "企业自筹费用";?>：</div>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['raised_enterprise'].$y ;?></div>
            </div>
     	</div>
     	
        <div class="details_item_line">  
            <div class="details_item">
                <div class="form_left_title left"><?php echo "备注" ;?>：</div>
                <div class="form_right_input left"><?php echo $cost['DevelopmentCost']['remark'] ;?></div>
            </div>
        </div> 
        
       <div class="details_item_line">  
            <div class="details_item">
                <div class="form_left_title left"><?php echo "附件" ;?>：</div>
                <div class="left">
                	<div class="file_category_list">
		        		<div id="filelist0" class="file_lists">
		        			<?php $dan="'";
			                	if($attachments){?>
		        			<ul class="picture_attach">
		        				<?php
			                	foreach($attachments as $attachment){
			                			$fname=$attachment["file_name"];
			                			$fpath=$attachment["file_path"];
			                			$fid=$attachment["id"];
			                			$createdtime=date("Y-m-d",strtotime($attachment["created"]));
			                			$isimg=$str->checkimg($fname);
			                			if($isimg){
											echo "<li>";
											echo '<div class="picture_info">';
											echo "<span>".$fname."</span>";
											echo "<span class='source_upload_date'>".$createdtime.$html->link("下载",'/projects/download/'.$attachment["id"],null)."</span>";
											echo "</div>";
											
											if($user['isadmin'] || $user['isgroupadmin'] || $second_ownerid==$user['id']){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
											}
											$img=$html->image("/".$fpath);
											echo "<span>".$html->link($img,'javascript:void(0);',array('onclick'=>"openimg(".$dan."f".$fid.$dan.")",'escape' => false))."</span>";
											echo "<div style='display:none' id='f".$fid."' title='".$fname."'>".$img."</div>";
											
											echo "</li>";
										}
									}
			                	?>
		        				<div class="clear"></div>
		        			</ul>
		        			<ul class="file_attach">
			                	<?php
			                	foreach($attachments as $attachment){
			                			$fname=$attachment["file_name"];
			                			$isimg=$str->checkimg($fname);
			                			if(!$isimg){
											echo "<li>";
											echo "<span>".$html->link($fname,'/projects/download/'.$attachment["id"],null)."</span>";
											echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
											if($user['isadmin'] || $user['isgroupadmin'] || $second_ownerid==$user['id']){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
											}
											echo "</li>";
										}
									}
			                	?>
			                	
			                </ul>
			                <div class="clear"></div>
			                <?php 
			                	}else{
									echo '<div class="form_right_input left">暂无文件</div>';
								}
			                ?>
		                </div>
		             </div>
				</div>
            </div>
        </div>
        <div class="right_side_operate_area">
			<div class="right_side_title left">
				<h3>
					研发费用投入情况			
				</h3>
			</div>
			<div class="right long_word_btn">
				<?php 
				echo $html->link("编辑投入清单","/companys/deplist/");	
				?>
			</div>
		    <div class="clear"></div>
		</div>
		<div class="items_list" >	
			<table>
				<tr>
					<th>项目名称</th>
					<th>起始日期</th>
					<th>完成日期</th>
					<th>所处阶段</th>
					<th>预期投入</th>
					<th>项目投入</th>
					<th>累计投入</th>
					<th>是否备案</th>
					<th>附件</th>		
					<th>&nbsp;</th>
				</tr>
			<?php 
				if(!empty($lists)){
					foreach ($lists as $list)
					{
						$id=$list["DevelopmentList"]["id"];
						echo "<tr class='per_list'>";
						$name=$list['DevelopmentList']['name'];
						echo "<td><span title='".$name."'>".$str->sub_len($name,20)."</span></td>";
						$start_date = $list['DevelopmentList']['start_date'];
						if(!empty($start_date)){
							$start_date=date("Y-m-d",strtotime($start_date));
						}
						echo "<td>".$start_date."</td>";
						$finish_date=$list['DevelopmentList']['finish_date'];
						if(!empty($finish_date)){
							$finish_date=date("Y-m-d",strtotime($finish_date));
						}
						echo "<td>".$finish_date."</td>";	
						echo "<td>".$list['DevelopmentList']["stage"]."</td>";
						echo "<td>".$list['DevelopmentList']["ex_investment"]."元</td>";
						echo "<td>".$list['DevelopmentList']["act_investment"]."元</td>";
						echo "<td>".$list['DevelopmentList']["total_investment"]."元</td>";
						$record = $list['DevelopmentList']["record"];
						echo "<td>".$str->getisflag($record)."</td>";
						echo "<td>";
			                	$attachments=$list['Attachment'];
			                	if($attachments){
				                	$dan="'";
//				                	$second_ownerid=$form->value('Company.second_owner');
				                	foreach($attachments as $attachment) {
											echo "<li>";
											echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
											echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
											if($user['isadmin'] || $user['isgroupadmin'] || $second_ownerid==$user['id']){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
											}
											echo "</li>";
									}
								}else{
									echo "暂无文件";
								}
			                	
			             echo "</td>";							
						echo "</tr>";
			        }
		        }
		    ?>
			</table>
		</div>
    </div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>